package com.mh.www.mh_frame.util;

import com.mh.www.mh_frame.view.fragment.BaseFragment;
import com.mh.www.mh_frame.view.fragment.DailyInquiryFragment;
import com.mh.www.mh_frame.view.fragment.FieldInspectionFragment;
import com.mh.www.mh_frame.view.fragment.MyDailyFragment;
import com.mh.www.mh_frame.view.fragment.ProgressManageFragment;
import com.mh.www.mh_frame.view.fragment.QueryEntryFragment;

/**
 * 作者： itheima
 * 时间：2016-10-17 10:42
 * 网址：http://www.itheima.com
 */

public class FragmentFactory {

    private static QueryEntryFragment mQueryEntryFragment;
    private static DailyInquiryFragment mDailyInquiryFragment;
    private static MyDailyFragment mMyDailyFragment;
    private static ProgressManageFragment mProgressManageFragment;
    private static FieldInspectionFragment mFieldInspectionFragment;

    public static BaseFragment getFragment(int position){
        BaseFragment baseFragment = null;
        switch (position) {
            case 0:
                if (mQueryEntryFragment==null){
                    mQueryEntryFragment = new QueryEntryFragment();
                }
                baseFragment = mQueryEntryFragment;
                break;
            case 1:
                if (mDailyInquiryFragment==null){
                    mDailyInquiryFragment = new DailyInquiryFragment();
                }
                baseFragment = mDailyInquiryFragment;
                break;
            case 2:
                if (mMyDailyFragment==null){
                    mMyDailyFragment = new MyDailyFragment();
                }
                baseFragment = mMyDailyFragment;
                break;
            case 3:
                if (mProgressManageFragment==null){
                    mProgressManageFragment = new ProgressManageFragment();
                }
                baseFragment = mProgressManageFragment;
                break;
            case 4:
                if (mFieldInspectionFragment==null){
                    mFieldInspectionFragment = new FieldInspectionFragment();
                }
                baseFragment = mFieldInspectionFragment;
                break;
        }
        return baseFragment;

    }

}
